# 记得修改服务器上面的分页数目为20行分页
React = require('react')
Card = require('antd-mobile/lib/card')
# ListView = require('antd-mobile/lib/list-view')
Flex = require('antd-mobile/lib/flex')
Icon = require('antd-mobile/lib/icon')
Toast = require('antd-mobile/lib/toast')
RefreshControl = require('antd-mobile/lib/refresh-control')
{View,Image,Text,ScrollView,TouchableHighlight,StyleSheet,Navigator,ListView,TouchableOpacity} = require('react-native')
Dimensions = require('Dimensions')
{ width, height } = Dimensions.get('window')
{View} = require('react-native')
{fetchGetList,fetchRefreshList} = require('../actions/page_tz.js')
{connect} = require('react-redux')
_ = require('underscore')

backImg = require('../img/back.png')
searchIcon = require('../img/search_white.png')
basePage = require('../mixins/basePage.js')
DescPage = require('./page_msgDetail.js')

Page_Gd = React.createClass
  mixins:[basePage]
  rowClick:(model)->
    {navigator} = @props
    setTimeout ->
      navigator.push
        component:DescPage
        name:'inAttempDesc'
        title:'详情'
        params:
          model:model
    ,200
  _renderHeader:->
      <View style={{flexDirection:'row',flex:0,height:60,alignItems:'center', justifyContent:'center',backgroundColor:'#0066FF'}}>
        <View style={{flex:1,padding:10}}>
          <TouchableOpacity onPress={=>@props.navigator.pop()}>
            <Image source={backImg}  style={{height:30,width:30,resizeMode:'contain'}}/>
          </TouchableOpacity>
        </View>
        <View style={{flex:1,justifyContent:'center',alignItems:'center'}}>
          <Text style={{fontSize:20,color:'#ffffff'}}>规定</Text>
        </View>
        <View style={{flex:1,alignItems:'flex-end',padding:10}}>
          <TouchableOpacity onPress={@_showActionSheet}>
          </TouchableOpacity>
        </View>
      </View>
  _renderListColumns:->

  _renderRow:(rowData,sectionID,rowID,highlightRow)->
    <TouchableHighlight onPress={@rowClick.bind(@,rowData)} key={rowData.INNO}>
      <View style={styles.row}>
        <Text style={[styles.text,{fontWeight:'bold'}]}>
          {rowData.VCTITLE}
        </Text>
        <View style={{flexDirection:'row'}}>
          <Text style={styles.text}>
            {rowData.DTTIME}
          </Text>
        </View>
      </View>
    </TouchableHighlight>

styles = StyleSheet.create
  row:
    flexDirection:'column'
    justifyContent:'center'
    padding:10
    backgroundColor:'#F6F6F6'
  text:
    flex:1

mapStateToProps = (state)->
  list:state.page_gd.list
  isLoading:state.page_gd.isLoading
  pageIndex:state.page_gd.pageIndex
  completed:state.page_gd.completed
  refreshing:state.page_gd.refreshing
  lastFetchTime:state.page_gd.lastFetchTime
  connected:state.appState.connected  
mapDispatchToProps = (dispatch,wonProps)->
  fetchGet:(pageNum)->
    dispatch fetchGetList(pageNum,'4')
  fetchRefresh:->
    dispatch fetchRefreshList('4')

module.exports = connect(mapStateToProps,mapDispatchToProps)(Page_Gd)
